{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "initial_id",
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "\"\"\"\n",
    "题目：温度数据分析\n",
    "某一城市一周的最高气温（摄氏度）为[28,30,29,31,32,30,29]\n",
    "- 计算平均气温、最高气温和最低气温\n",
    "- 找出气温超过30摄氏度的天数\n",
    "\"\"\""
   ]
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-06T14:20:00.851998Z",
     "start_time": "2025-09-06T14:20:00.842519Z"
    }
   },
   "cell_type": "code",
   "source": [
    "import numpy as np\n",
    "temps = np.array([28,30,29,31,32,30,29])\n",
    "print('平均气温：', '%.2f'%np.mean(temps))\n",
    "print('最高气温：', np.max(temps))\n",
    "print('最低气温：', np.min(temps))\n",
    "print('气温超过30的次数：', np.sum(temps > 30))\n",
    "print('气温超过30的索引：', np.where(temps > 30))\n",
    "print('气温超过30的元素：', temps[np.where(temps > 30)])\n",
    "print('气温超过30的元素：', np.extract(temps > 30, temps))"
   ],
   "id": "a3aa7872da0d6bde",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "平均气温： 29.86\n",
      "最高气温： 32\n",
      "最低气温： 28\n",
      "气温超过30的次数： 2\n",
      "气温超过30的索引： (array([3, 4]),)\n",
      "气温超过30的元素： [31 32]\n",
      "气温超过30的元素： [31 32]\n"
     ]
    }
   ],
   "execution_count": 7
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
